package org.java.detail.web;

import org.java.detail.service.CreateDetailHtml;
import org.java.detail.service.DetailService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author WHQ
 * @version 1.0
 * @date 2022-3-10 0010 上午 10:52
 */
@Controller
public class DetailController {
    @Resource
    private CreateDetailHtml createDetailHtml;
    @Resource
    private DetailService detailService;
    @GetMapping("/item/{id}.html")
    public String showDetail(@PathVariable("id") Long id, Model model){
        System.out.println("id为"+id+"的页面");
        Map map = detailService.findSkuDetailById(id);
        model.addAllAttributes(map);
        //开始生成静态页面
        createDetailHtml.createDetail(id);
        return "/item";
    }
}
